package com.rdgk.newtech.controller;

import com.alibaba.fastjson.JSONObject;
import com.rdgk.newtech.service.OrgAnalyseService;
import com.rdgk.newtech.service.ProjectService;
import com.rdgk.newtech.util.CommonUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: bguan
 * @description: 机构动态Controller
 */
@RestController
@RequestMapping("/organalyse")
public class OrgAnalyseController {

	@Autowired
	private OrgAnalyseService orgAnalyseService;

	/**
	 * 重点机构列表
	 */
	@PostMapping("/importantOrgList")
	public JSONObject importantOrgList(HttpServletRequest request) {
		String topicId = request.getParameter("topicId");
		return CommonUtil.successJson(orgAnalyseService.importantOrgList(Integer.parseInt(topicId),null));
	}

    /**
     * 机构动态信息区域分布
     */
    @PostMapping("/technologyRegionalDistribution")
    public JSONObject technologyRegionalDistribution(HttpServletRequest request) {
		String topicId = request.getParameter("topicId");
        return CommonUtil.successJson(orgAnalyseService.technologyRegionalDistribution(Integer.parseInt(topicId),null));
    }

	/**
	 * 某个专题下面所有机构合作关系
	 */
	@PostMapping("/allOrgCooperateNet")
	public JSONObject allOrgCooperateNet(HttpServletRequest request) {
		String topicId = request.getParameter("topicId");
		String keyword = request.getParameter("keyword");
		return CommonUtil.successJson(orgAnalyseService.allOrgCooperateNet(Integer.parseInt(topicId),keyword));
	}

	/**
	 * 获取某个机构的详细信息
	 */
	@PostMapping("/orgDetails")
	public JSONObject orgDetails(HttpServletRequest request) {
		String topicId = request.getParameter("topicId");
		String orgId = request.getParameter("orgId");
		return CommonUtil.successJson(orgAnalyseService.orgDetails(Integer.parseInt(topicId),Integer.parseInt(orgId)));
	}
}
